<?php

class wxpay_web {

    private $config;
    private $url;

//主入口
    public function config($config = null) {
        $this->config = $config;
        $data = array(
            'service' => 'Pay.Request',
            'type' => 'Wechatnative',
            'partner' => $this->config['id'],
            'sign' => md5(md5($this->config['id'] . $this->config['key'])),
            'email' => $this->config['pay_type_data']['user']['val'],
            'charset' => strtolower('utf-8'),
            'subject' => $this->config['title'],
            'out_trade_no' => $this->config['code'],
            'total_fee' => $this->config['money'],
            'notify_url' => $this->config['NotifyUrl'],
            'return_url' => $this->config['ReturnUrl']
        );

        $this->url = 'http://v2.api.haoteam.net/?' . http_build_query($data);
    }

//发送
    public function send_pay() {
        header("Location: " . $this->url);
        exit;
    }

}
